//
// Created by vanweilin on 2022/9/5 1:09.
//

#ifndef LEARN_OPENCV_SIMPLEVIDEOCAPTURE_HPP
#define LEARN_OPENCV_SIMPLEVIDEOCAPTURE_HPP

#include "../collection.h"
#include "opencv2/opencv.hpp"

namespace SimpleVideo {
    using namespace cv;
    using namespace Util;

    void headVideo() {
        VideoCapture capture(
                "D:\\BaiduNetdiskDownload\\cxk.avi");
        capture.set(CAP_PROP_FRAME_WIDTH, 1920);
        capture.set(CAP_PROP_FRAME_HEIGHT, 1080);
        capture.set(CAP_PROP_FOURCC, VideoWriter::fourcc('M', 'J', 'P', 'G'));
        // capture.set(CAP_PROP_FPS, 30);//帧数

        //capture.set(CAP_PROP_BRIGHTNESS, 1);//亮度 50
        //capture.set(CAP_PROP_CONTRAST, 40);//对比度 50
        //capture.set(CAP_PROP_SATURATION, 50);//饱和度 50
        //capture.set(CAP_PROP_HUE, 50);//色调 0
        //capture.set(CAP_PROP_EXPOSURE, 50);//曝光 -12
        //打印摄像头参数
        printf("width = %.2f\n", capture.get(CAP_PROP_FRAME_WIDTH));
        printf("height = %.2f\n", capture.get(CAP_PROP_FRAME_HEIGHT));
        printf("fbs = %.2f\n", capture.get(CAP_PROP_FPS));
        printf("brightness = %.2f\n", capture.get(CAP_PROP_BRIGHTNESS));
        printf("contrast = %.2f\n", capture.get(CAP_PROP_CONTRAST));
        printf("saturation = %.2f\n", capture.get(CAP_PROP_SATURATION));
        printf("hue = %.2f\n", capture.get(CAP_PROP_HUE));
        printf("exposure = %.2f\n", capture.get(CAP_PROP_EXPOSURE));
        while (1) {
            Mat frame;
            capture >> frame;
            imshow("读取视频", frame);
            waitKey(1000 / 30);
        }

    }
}
#endif //LEARN_OPENCV_SIMPLEVIDEOCAPTURE_HPP
